import './NewsItems.less'
import PropTypes from "prop-types";

import {Image} from "antd-mobile";
import {Link} from "react-router-dom";
const NewsItem = (props) => {
    const newsInfo = props.newsInfo
    if(newsInfo === null) return null
    let { id, title , hint , images } = newsInfo
    if(!Array.isArray(images)) images = ['']

    return <div className={'news-item-box'}>
        <Link to={`/detail/${id}`} >
            <div className="content">
                <h4 className="title">{title}</h4>
                <p className="author">{hint}</p>
            </div>
            <Image src={images[0]} lazy />
        </Link>
    </div>

};

NewsItem.defaultProps = {
    newsInfo : null
}

NewsItem.propTypes = {
    newsInfo:PropTypes.object
}


export default NewsItem
